package com.fantastic.web.controller.app;

import com.fantastic.common.exception.enums.RespStatusInfo;
import com.fantastic.common.result.ResultData;
import com.fantastic.model.pojo.zjs.Cart;
import com.fantastic.service.zjs.CartService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: rxx
 * @since: 2024/6/5 19:24
 * @description: 购物车信息请求控制器
 */
@RestController
@RequestMapping("/app")
public class CartController {

    @Resource
    private CartService cartService;

    /**
     * 查询单个账号下所有的购物车信息
     *
     * @param accountId
     * @return
     */
    @GetMapping("/listCartVoApp")
    public ResultData getCartVoApp(Integer accountId) {
        return new ResultData(RespStatusInfo.OK, cartService.listCartVo(accountId));
    }

    /**
     * 添加购物车信息
     *
     * @param cart
     * @return
     */
    @PostMapping("/insertCartApp")
    public ResultData insertCartApp(Cart cart) {
        return new ResultData(RespStatusInfo.OK, cartService.insertCart(cart));
    }

    /**
     * 修改购物车信息
     *
     * @param cart
     * @return
     */
    @PostMapping("/updateCartApp")
    public ResultData updateCartApp(Cart cart) {
        return new ResultData(RespStatusInfo.OK, cartService.updateCart(cart));
    }


    /**
     * 删除购物车信息
     *
     * @param cart
     * @return
     */
    @PostMapping("/deleteCartApp")
    public ResultData deleteCartApp(Cart cart) {
        return new ResultData(RespStatusInfo.OK, cartService.deleteCart(cart));
    }

}
